<div class="loader"></div>
<h3>{{ $text_create }} {{ $title }}</h3>
{{ Form::open(array('url' => $base, 'id' => 'form')) }}
	
	<div class="form-group">
		{{ Form::label('name', $form_name) }}
		{{ Form::text('name', Input::old('form_name'), array('class' => 'form-control')) }}
		<span class="error text-danger" id="error_name"></span>
	</div>
	
	<div class="form-group">
		{{ Form::label('name', $form_name) }}
		<table class="table table-bordered">
			<thead>
				<tr>
					<th>Route</th>
					<th>Title</th>
					<th>Action</th>
				</tr>
			</thead>
			<tbody id="user_profile">
			</tbody>
			<tfoot>
				<tr>
					<td colspan="3">{{ Form::button($text_add, array('class' => 'btn btn-primary', 'id' => 'add')) }}</td>
				</tr>
			</tfoot>
		</table>	
	</div>

	{{ Form::submit($text_submit, array('class' => 'btn btn-primary', 'id' => 'submit', 'data-loading-text' => $text_loading)) }}
	{{ HTML::link( URL::to($base . '/'), $text_cancel, array('class' => 'btn btn-default', 'id'=> 'cancel')) }}

{{ Form::close() }}
<script type="text/javascript">
$("#add").click(function(){
	
	var html  =	'<tr class="tbl-row">';
		html += '	<td>{{ Form::text('user_profile[][module]', null, array('class' => 'form-control user_profile_module')) }}</td>';
		html +=	'	<td>{{ Form::text('user_profile[][title]', null, array('class' => 'form-control user_profile_title')) }}</td>';
		html +=	'	<td>{{ Form::button($text_remove, array('class' => 'btn btn-primary remove')) }}</td>';
		html += '</tr>';

	$('#user_profile').append(html);

	$('.user_profile_module').each(function(index, object) {
		$(object).attr('name', 'user_profile[' + index + '][module]');
	});

	$('.user_profile_title').each(function(index, object) {
		$(object).attr('name', 'user_profile[' + index + '][title]');
	});

	$('.remove').click(function(){
		var index = $('.remove').index(this);
		$(this).parents('tr.tbl-row');
	});
});
</script>
